<template>
  <div id="container">
    <div class="navbar">
      <img :src="logo" alt class="float-left" height="60px"/>
    </div>
    <div class="info">
      <div class="info-img">
        <img :src="docPic" alt height="120px"/>
        <p style="font-size:18px">医生注册</p>
      </div>
      <!-- <back-btn @myClose="goBack"></back-btn> -->
      <div class="info-title">登录信息</div>
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-position="right"
        label-width="200px"
        class="info-form"
      >
        <el-form-item label="手机号码" prop="mobile" class="ipt-item">
          <el-input v-model="ruleForm.mobile"></el-input>
        </el-form-item>
        <el-form-item label="手机验证码" prop="rectify" class="ipt-item">
          <!-- <el-input type="password" style="display:inline-block;width:77%"  v-model="ruleForm.rectify" placeholder="请输入密码/验证码" show-password clearable></el-input>
          <el-button type="default" size="medium" >获取验证码</el-button> -->
          <el-input placeholder="请输入内容" v-model="ruleForm.rectify" class="input-with-select">
            <el-button slot="append" type="default" size="medium">获取验证码</el-button>
          </el-input>
        </el-form-item>
        <el-form-item label="密码" prop="newPassword" class="ipt-item">
          <el-input v-model="ruleForm.newPassword" show-password></el-input>
        </el-form-item>
        <el-form-item label="确认密码" prop="confirmPassword" class="ipt-item">
          <el-input v-model="ruleForm.confirmPassword" show-password></el-input>
        </el-form-item>
      </el-form>

      <div class="info-title">账号信息</div>
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-position="right"
        label-width="200px"
        class="info-form"
      >
        <el-form-item label="姓名" prop="mobile" class="ipt-item">
          <el-input v-model="ruleForm.mobile"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" prop="rectify" class="ipt-item">
          <el-input v-model="ruleForm.rectify"></el-input>
        </el-form-item>
        <el-form-item label="所属医院" prop="newPassword" class="ipt-item">
          <el-input v-model="ruleForm.newPassword" show-password></el-input>
        </el-form-item>
        <el-form-item label="所属科室" prop="confirmPassword" class="ipt-item">
          <el-input v-model="ruleForm.confirmPassword" show-password></el-input>
        </el-form-item>
        <el-form-item>
          <el-checkbox v-model="checked">
            我已阅读并接受
            <a style="font-size:14px">《卡易远程医疗协同平用户服务协议》</a>
          </el-checkbox>
        </el-form-item>
      </el-form>
      <div class="info-bottom">
        <el-button type="primary" class="info-btn" @click="changePassword">确认</el-button>
        <el-button type="default" class="info-btn" @click="goLogin">返回</el-button>
      </div>
    </div>
  </div>
</template>
<script>
// import Logo from '@/assets/images/logo-light.png'
import DocPic from '@/assets/images/doctor_lg.png'
let logoFile = ''
if (window.g.isChangeLogo) {
  logoFile = 'logo-light-julei.png'
} else {
  logoFile = 'logo-light-kayi.png'
}
export default {
  data() {
    var validatePassword = (rule, value, callback) => {
      if (value.length <= 5) {
        callback(new Error('密码需要大于5位'))
      } else {
        callback()
      }
    }
    var validateRepassword = (rule, value, callback) => {
      if (value !== this.ruleForm.newPassword) {
        callback(new Error('密码不一致'))
      } else {
        callback()
      }
    }
    return {
      logo: require('@/assets/images/' + logoFile),
      docPic: DocPic,
      // pwdChange:false,
      ruleForm: {
        mobile: '', // 新密码
        rectify: '', // 验证码
        confirmPassword: '', // 再次新密码
        oldPassword: '' // 原密码
      },
      rules: {
        mobile: [
          { required: true, trigger: 'blur', validator: validatePassword }
        ],
        rectify: [
          { required: true, trigger: 'blur', validator: validatePassword }
        ],
        oldPassword: [
          { required: true, trigger: 'blur', validator: validatePassword }
        ],
        newPassword: [
          { required: true, trigger: 'blur', validator: validatePassword }
        ],
        confirmPassword: [
          { required: true, trigger: 'blur', validator: validateRepassword }
        ]
      },
      checked: false
    }
  },
  methods: {
    changePassword() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          //   this.ruleForm.newPassword = hex_md5(this.ruleForm.newPassword).toUpperCase();
          //   this.ruleForm.confirmPassword = hex_md5(this.ruleForm.confirmPassword).toUpperCase();
          //   this.ruleForm.oldPassword = hex_md5(this.ruleForm.oldPassword).toUpperCase();
          //   changePwdEncrypt(this.ruleForm)
          //     .then(res => {
          //       if (res && res.code == 10000) {
          //         this.$message({
          //           message: this.$t("home.modifySuccess"),
          //           type: "success"
          //         });
          //         // this.pwdChange = false;
          //       }else{
          //         this.$message({
          //           message: this.$t("home.incorrectPwd"),
          //           type: "warning"
          //           });
          //       }
          //     })
          //     .catch(err => {
          //       console.log(err);
          //     });
        }
      })
    },
    resetRuleForm() {
      this.ruleForm = {
        newPassword: '', // 新密码
        confirmPassword: '', // 再次新密码
        oldPassword: '' // 原密码
      }
    },
    goLogin() {
      this.$router.push({
        path: '/login'
      })
    }
    //  goBack(){
    //   this.$emit('goBack');
    // },
  }
}
</script>

<style lang="scss" scoped>
$bg: #31414f;
#container {
  width: 100%;
  //   height: 100%;
  position: relative;
  overflow: hidden;
  background-color: $bg;
}
.navbar {
  height: 60px;
  overflow: hidden;
  position: relative;
  background-color: #061528;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
}
.info {
  margin: 100px 120px;
  position: relative;
  background: #fff;
  border-radius: 7px;
  padding: 15px 0px 0px;
  .info-img {
    text-align: center;
    margin-top: -86px;
  }
  .info-title {
    margin: 20px 40px;
    padding-left: 15px;
    height: 40px;
    line-height: 40px;
    background-color: #f2f2f2;
  }
  .info-form {
    width: 75%;
    padding: 30px 0;
    padding-left: 15%;
  }
  .info-bottom {
    background-color: #f5f5f5;
    text-align: center;
    padding: 15px;
    .info-btn {
      width: 120px;
      margin-right: 20px;
    }
  }
}
</style>
